﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gui;

namespace NHibernate.App
{
    public interface IFactory
    {
        void ThreadProc();
    }

    public class Factory
    {
        private int userId_;
        public Factory(int id)
        {
            userId_ = id;
        }
        public void createForm(string userType_)
        {
            if (userType_.Equals("superuser"))
            {
                ConcreteSuperUserForm form = new ConcreteSuperUserForm();
                System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(form.ThreadProc));

                t.Start();
                Application.ExitThread();
            }
            else if (userType_.Equals("teacher"))
            {
                ConcreteTeacherForm form = new ConcreteTeacherForm();
                System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(form.ThreadProc));

                t.Start();
                Application.ExitThread();
            }
            else if (userType_.Equals("student"))
            {
                ConcreteStudentForm form = new ConcreteStudentForm(userId_);
                System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(form.ThreadProc));

                t.Start();
                Application.ExitThread();
            }
        }
    }

    public class  ConcreteSuperUserForm : IFactory
    {
        public void ThreadProc()
        {
            Application.Run(MainFormSuperUser.getInstance());
        }
    }

    public class ConcreteTeacherForm : IFactory
    {
        public void ThreadProc()
        {
            Application.Run(MainFormTeacher.getInstance());
        }
    }

    public class ConcreteStudentForm : IFactory
    {
        private int userId_;
        public ConcreteStudentForm(int id)
        {
            userId_ = id;
        }
        public void ThreadProc()
        {
            Application.Run(MainFormStudent.getInstance(userId_));
        }
    }
}
